package oo;

import java.util.Hashtable;
import java.util.ResourceBundle;

import javax.faces.context.FacesContext;

public class Translator extends Hashtable<String, String> {
	private static final long serialVersionUID = 1L;

	public static ResourceBundle getResourceBundle() {
    	FacesContext context = FacesContext.getCurrentInstance();
    	return (ResourceBundle)  ResourceBundle.getBundle(context.getApplication().getMessageBundle(), context.getViewRoot().getLocale() );
    }
    
    public static String translate(String key) {
    	try {
    		return getResourceBundle().getString(key);
    	}
    	catch(Exception exc) {
    		exc.printStackTrace();
    		return  "??-" + key + "??";    		
    	}
    	
    }
    
	public String get(Object key) {
    	return Translator.translate((String)key);
    }
    


}
